package com.interest.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.interest.business.domain.vo.OrderQueryVo;
import com.interest.common.annotation.Log;
import com.interest.common.core.controller.BaseController;
import com.interest.common.core.domain.AjaxResult;
import com.interest.common.core.page.TableDataInfo;
import com.interest.common.enums.BusinessType;
import com.interest.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.interest.business.domain.InterestOrder;
import com.interest.business.service.IInterestOrderService;

/**
 * 订单记录Controller
 * 
 * @author ruoyi
 * @date 2023-11-11
 */
@RestController
@RequestMapping("/business/order")
public class InterestOrderController extends BaseController
{
    @Autowired
    private IInterestOrderService interestOrderService;

    /**
     * 查询订单记录列表
     */
    @PreAuthorize("@ss.hasPermi('business:order:list')")
    @GetMapping("/list")
    public TableDataInfo list(OrderQueryVo interestOrder)
    {
        startPage();
        List<InterestOrder> list = interestOrderService.selectInterestOrderList(interestOrder);
        return getDataTable(list);
    }

    /**
     * 导出订单记录列表
     */
    @PreAuthorize("@ss.hasPermi('business:order:export')")
    @Log(title = "订单记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderQueryVo interestOrder)
    {
        List<InterestOrder> list = interestOrderService.selectInterestOrderList(interestOrder);
        ExcelUtil<InterestOrder> util = new ExcelUtil<InterestOrder>(InterestOrder.class);
        util.exportExcel(response, list, "订单记录数据");
    }

    /**
     * 获取订单记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:order:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(interestOrderService.selectInterestOrderById(id));
    }
}
